﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace SQL.SQLite
{
    public class Statistics : INotifyPropertyChanged
    {
        private int total = 0;
        private int ok = 0;
        private int ng = 0;
        private int other = 0;

        public void Init()
        {
            Total = 0;
            Ok = 0;
            Ng = 0;
            Other = 0;
        }
        public int Total
        {
            get => total; set
            {
                total = value;
                NotifyPropertyChanged();
            }
        }
        public int Ok
        {
            get => ok; set
            {
                ok = value;
                Total = Ok + Ng + Other;
                NotifyPropertyChanged();
            }
        }
        public int Ng
        {
            get => ng; set
            {
                ng = value;
                Total = Ok + Ng + Other;
                NotifyPropertyChanged();
            }
        }
        public int Other
        {
            get => other; set
            {
                other = value;
                Total = Ok + Ng + Other;
                NotifyPropertyChanged();
            }
        }

        public override string ToString()
        {
            return "total:" + Total + " ok:" + Ok + " ng:" + Ng + " other:" + Other;
        }


        public event PropertyChangedEventHandler PropertyChanged;
        // This method is called by the Set accessor of each property.
        // The CallerMemberName attribute that is applied to the optional propertyName
        // parameter causes the property name of the caller to be substituted as an argument.
        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
